Make sure that subpixbufs are properly aligned for
authorMatthias Clasen <maclas@gmx.de>
Thu, 8 Jul 2004 03:48:10 +0000 (03:48 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 8 Jul 2004 03:48:10 +0000 (03:48 +0000)
Wed Jul  7 23:44:32 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkimage.c (gtk_image_expose): Make sure that subpixbufs
are properly aligned for gdk_pixbuf_saturate_and_pixelate(),
in order to avoid rendering artifacts from misaligned
pixelation patterns.  (#145585, Felipe Heidrich, Billy Biggs)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkimage.c

index 80d29ccf133866363ae181875f44ef3370846d17..10ce76ad3b5c2f471ffad98314665b22974f0dab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jul  7 23:44:32 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkimage.c (gtk_image_expose): Make sure that subpixbufs
+       are properly aligned for gdk_pixbuf_saturate_and_pixelate(),
+       in order to avoid rendering artifacts from misaligned 
+       pixelation patterns.  (#145585, Felipe Heidrich, Billy Biggs)
+
 2004-07-07  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtktreeview.c: 
index 80d29ccf133866363ae181875f44ef3370846d17..10ce76ad3b5c2f471ffad98314665b22974f0dab 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jul  7 23:44:32 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkimage.c (gtk_image_expose): Make sure that subpixbufs
+       are properly aligned for gdk_pixbuf_saturate_and_pixelate(),
+       in order to avoid rendering artifacts from misaligned 
+       pixelation patterns.  (#145585, Felipe Heidrich, Billy Biggs)
+
 2004-07-07  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtktreeview.c: 
index 80d29ccf133866363ae181875f44ef3370846d17..10ce76ad3b5c2f471ffad98314665b22974f0dab 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jul  7 23:44:32 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkimage.c (gtk_image_expose): Make sure that subpixbufs
+       are properly aligned for gdk_pixbuf_saturate_and_pixelate(),
+       in order to avoid rendering artifacts from misaligned 
+       pixelation patterns.  (#145585, Felipe Heidrich, Billy Biggs)
+
 2004-07-07  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtktreeview.c: 
index 80d29ccf133866363ae181875f44ef3370846d17..10ce76ad3b5c2f471ffad98314665b22974f0dab 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jul  7 23:44:32 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkimage.c (gtk_image_expose): Make sure that subpixbufs
+       are properly aligned for gdk_pixbuf_saturate_and_pixelate(),
+       in order to avoid rendering artifacts from misaligned 
+       pixelation patterns.  (#145585, Felipe Heidrich, Billy Biggs)
+
 2004-07-07  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtktreeview.c: 
index 4b45182c82bf402b85c0b502bf93d015d723825b..cf9b07a7355183d179c8c56f36717b3574dd5058 100644 (file)
@@ -1207,6 +1207,44 @@ animation_timeout (gpointer data)
   return FALSE;
 }
 
+/*
+ * Like gdk_rectangle_intersect (dest, src, dest), but make 
+ * sure that the origin of dest is moved by an "even" offset. 
+ * If necessary grow the intersection by one row or column 
+ * to achieve this.
+ *
+ * This is necessary since we can't pass alignment information
+ * for the pixelation pattern down to gdk_pixbuf_saturate_and_pixelate(), 
+ * thus we have to makesure that the subimages are properly aligned.
+ */
+static gboolean
+rectangle_intersect_even (GdkRectangle *src, 
+                         GdkRectangle *dest)
+{
+  gboolean isect;
+  gint x, y;
+
+  x = dest->x;
+  y = dest->y;
+  isect = gdk_rectangle_intersect (dest, src, dest);
+
+  if ((dest->x - x + dest->y - y) % 2 != 0)
+    {
+      if (dest->x > x)
+       {
+         dest->x--;
+         dest->width++;
+       }
+      else
+       {
+         dest->y--;
+         dest->height++;
+       }
+    }
+  
+  return isect;
+}
+
 static gint
 gtk_image_expose (GtkWidget      *widget,
                  GdkEventExpose *event)
@@ -1272,8 +1310,7 @@ gtk_image_expose (GtkWidget      *widget,
           gdk_drawable_get_size (image->data.pixmap.pixmap,
                                  &image_bound.width,
                                  &image_bound.height);
-
-         if (gdk_rectangle_intersect (&image_bound, &area, &image_bound) &&
+         if (rectangle_intersect_even (&area, &image_bound) &&
              needs_state_transform)
             {
               pixbuf = gdk_pixbuf_get_from_drawable (NULL,
@@ -1295,7 +1332,7 @@ gtk_image_expose (GtkWidget      *widget,
           image_bound.width = image->data.image.image->width;
           image_bound.height = image->data.image.image->height;
 
-         if (gdk_rectangle_intersect (&image_bound, &area, &image_bound) &&
+         if (rectangle_intersect_even (&area, &image_bound) &&
              needs_state_transform)
             {
               pixbuf = gdk_pixbuf_get_from_image (NULL,
@@ -1314,8 +1351,9 @@ gtk_image_expose (GtkWidget      *widget,
         case GTK_IMAGE_PIXBUF:
           image_bound.width = gdk_pixbuf_get_width (image->data.pixbuf.pixbuf);
           image_bound.height = gdk_pixbuf_get_height (image->data.pixbuf.pixbuf);          
+         
 
-         if (gdk_rectangle_intersect (&image_bound, &area, &image_bound) &&
+         if (rectangle_intersect_even (&area, &image_bound) &&
              needs_state_transform)
            {
              pixbuf = gdk_pixbuf_new_subpixbuf (image->data.pixbuf.pixbuf,
@@ -1403,7 +1441,7 @@ gtk_image_expose (GtkWidget      *widget,
          gdk_gc_set_clip_origin (widget->style->black_gc, mask_x, mask_y);
        }
 
-      if (gdk_rectangle_intersect (&image_bound, &area, &image_bound))
+      if (rectangle_intersect_even (&area, &image_bound))
         {
           if (pixbuf)
             {